<template>
  <div class="houseManage">
    <h-header></h-header>
    <div class="content">
      <div class="sidebar">
        <div class="main-title">
          <i class="iconfont icon-4-copy"></i>
          <span class="font-18 text">菜单</span>
        </div>
        <div class="menu">
          <!-- <div class="menu-item">
            <p class="font-16 title" :class="{choosed:this.change=='map1'}" @click="changetab('map1')">房产清单</p>
            <p class="font-16 title" :class="{choosed:this.change=='map2'}" @click="changetab('map2')">数据导入</p>
          </div>-->
          <div class="menu-item" v-for="item in sideMenu" :key="item.id">
            <p class="font-16 title" @click="changetab(item.hash.funcname)" :class="{choosed:change==item.hash.funcname}">{{item.hash.funcname}}</p>
          </div>
        </div>
      </div>
      <div class="main-content">
        <div class="search_h clearfix">
          <p>
            <a href="#">{{showTitle}}</a>
          </p>
        </div>
        <div v-show="this.change=='房产清单'">
          <div class="search_div">
            <table width="100%">
              <tr>
                <td width="12%" align="right">管理单位：</td>
                <td width="21%">
                  <select name class="selectC" v-model="jiedao">
                    <option value="" selected>全部</option>
                    <option :value="item.hash.orgid" v-for="item in zpArr" :key="item.id">{{item.hash.orgname.replace(/;/g,"&nbsp;")}}</option>
                  </select>
                </td>
                <!-- <td width="12%" align="right">房产类型：</td>
                <td width="21%">
                  <select name id class="selectC" v-model="htype">
                    <option value selected>全部</option>
                    <option
                      :value="item.hash.code_name"
                      v-for="item in housedata3"
                      :key="item.id"
                    >{{item.hash.code_name}}</option>
                  </select>
                </td> -->
                <td align="right">房产地址：</td>
                <td width="20%">
                  <input type="text" v-model="haddr">
                </td>
                <td align="right">资产编号：</td>
                <td width="20%">
                  <input type="text" v-model="hnum">
                </td>

              </tr>
              <tr>

                <td align="right">审核状态：</td>
                <td>
                  <select name id=" " class="selectC" v-model="checkstatus">
                    <option value="" selected style="display:none;">全部</option>
                    <option value="">全部</option>
                    <option value="0">暂存</option>
                    <option value="1">待审核</option>
                    <option value="2">审核通过</option>
                    <option value="3">审核未通过</option>
                    <option value="10">归档</option>
                  </select>
                </td>
                <td align="right">所属单位：</td>
                <td width="20%">
                  <input type="text" v-model="danwei2">
                </td>
                <td align="right">所属区域：</td>
                <td width="20%">
                  <select name class="selectC" v-model="region">
                    <option value="" selected>全部</option>
                    <option :value="item.hash.code_id" v-for="item in regionArr" :key="item.id">{{item.hash.code_name}}</option>
                  </select>
                </td>

                <!-- <td width="12%" align="right">所属单位：</td>
                <td width="21%">
                  <select name class="selectC" v-model="jiedao">
                    <option value="" selected style="display:none;">全部</option>
                    <option
                      :value="item.hash.orgid"
                      v-for="item in zpArr"
                      :key="item.id"
                    >{{item.hash.orgname.replace(/;/g,"&nbsp;")}}</option>
                  </select>
                </td> -->
              </tr>
              <tr>
                <td align="right">产证编号：</td>
                <td width="20%">
                  <input type="text" v-model="certnum">
                </td>
                <td align="right">房产状态：</td>
                <td width="20%">
                  <select name class="selectC" v-model="hstatus">
                    <option value="" selected>全部</option>
                    <option :value="item.hash.code_id" v-for="item in hstatusArr" :key="item.id">{{item.hash.code_name}}</option>
                  </select>
                </td>
              </tr>
            </table>

            <div class="searchbtn" @click="searchHouse(1)">搜索</div>
          </div>
          <div style="padding-left: 30px">
            <div class="search-add">
              <nuxt-link tag="span" :to="{name: 'baseInfo'}" class="zhipai">新增</nuxt-link>
              <span class="zhipai" @click="dozhipai" style="background:#67c23a" v-if="showzb">指派房产</span>
            </div>
            <div class="content_div">
              <!-- <table width="100%" class="table">
                <thead>
                  <tr>
                    <th>序号</th>
                    <th>资产编号</th>
                    <th>产证编号</th>
                    <th>资产所在地址</th>
                    <th>所属街镇</th>
                    <th>登记时间</th>
                    <th>提交人</th>

                    <th>审核状态</th>
                    <th>审核人</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody>
                  <nuxt-link tag="tr" :to="{name: 'searchDetail',query:{hid:item.hash.hid}}" v-for="(item,index) in alldata" :key="item.id"
                    v-if="item.hash.hnum"
                  >
                    <td nowrap="nowrap">{{index+1}}</td>
                    <td nowrap="nowrap">{{item.hash.hnum}}</td>
                    <td nowrap="nowrap">{{item.hash.certnum}}</td>
                    <td>{{item.hash.haddr}}</td>
                    <td>{{item.hash.jiedao}}</td>
                    <td nowrap="nowrap">{{item.hash.intime}}</td>
                    <td nowrap="nowrap">{{item.hash.htype}}</td>
                    <td nowrap="nowrap">{{item.hash.htype}}</td>
                    <td nowrap="nowrap">{{item.hash.checkstatus}}</td>
                    <td nowrap="nowrap">

                      <nuxt-link tag="span" :to="{name: 'detailInfo',query:{hid:item.hash.hid}}" v-show="item.hash.checkstatus=='暂存'||item.hash.checkstatus=='审核未通过'||item.hash.checkstatus=='审核通过'"><span class="lin_nor">编辑</span></nuxt-link>
                      <span @click.stop="deleteItem(index,item.hash.hid)" v-if="item.hash.checkstatus=='暂存'||item.hash.checkstatus=='审核未通过'"><span class="lin_nor">删除</span></span><span v-else>查看</span>
                    </td>
                  </nuxt-link>
                  <tr v-else>
                    <td colspan="10">暂无数据</td>
                  </tr>
                </tbody>
              </table>-->
              <el-table ref="multipleTable" :data="alldata" border style="width:96%;margin:20px auto" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55" :selectable="checkboxInit"></el-table-column>
                <el-table-column type="index" width="50" label="序号"></el-table-column>
                <el-table-column prop="hash.zcbh" label="资产编号"></el-table-column>
                <!-- <el-table-column prop="hash.xh" label="xh"></el-table-column> -->
                <el-table-column prop="hash.haddr" label="房产地址"></el-table-column>
                <el-table-column prop="hash.dstatus" label="房产状态"></el-table-column>
                <el-table-column prop="hash.region" label="所属区域"></el-table-column>
                <el-table-column prop="hash.danwei2" label="所属单位"></el-table-column>
                <el-table-column prop="hash.glorg" label="管理单位"></el-table-column>
                <el-table-column prop="hash.certnum" label="产证编号"></el-table-column>

                <!-- <el-table-column prop="hash.htype" label="资产类型"></el-table-column> -->
                <!-- <el-table-column prop="hash.jiedao" label="所属街镇"></el-table-column> -->
                <el-table-column prop="hash.intime" label="登记时间"></el-table-column>
                <el-table-column prop="hash.op" label="登记人"></el-table-column>
                <el-table-column label="审核状态">
                  <template slot-scope="scope">
                    <span v-if="scope.row.hash.checkstatus== '0'">暂存</span>
                    <span v-else-if="scope.row.hash.checkstatus== '1'">待审核</span>
                    <span v-else-if="scope.row.hash.checkstatus== '2'">审核通过</span>
                    <span v-else-if="scope.row.hash.checkstatus== '10'" style="color:#f60">归档</span>
                    <span v-else style="color:#f60">审核未通过</span>
                  </template>
                </el-table-column>
                <el-table-column prop="hash.remark" label="审核说明"></el-table-column>
                <el-table-column prop="hash.checker" label="审核人"></el-table-column>
                <!-- <el-table-column prop="hash.glorg" label="管理单位"></el-table-column> -->
                <el-table-column prop="hash.occupyusername" label="占用人"></el-table-column>
                <el-table-column label="操作" width="260" headerAlign="center">
                  <template slot-scope="scope">
                    <el-button type="primary" size="small" @click="goSearchinfo(scope.row)">查看</el-button>
                    <!-- &&dept==scope.row.hash.glorgid -->
                    <el-button v-if="scope.row.hash.checkstatus!=='1'&&scope.row.hash.checkstatus!=='10'&&(scope.row.hash.occupyuser==''||scope.row.hash.occupyuser==pid)" type="primary" size="small" @click="goDetail(scope.row)">编辑</el-button>
                    <el-button v-if="(scope.row.hash.checkstatus=='0'||scope.row.hash.checkstatus=='3')&&(scope.row.hash.occupyuser==''||scope.row.hash.occupyuser==pid)" type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
                    <el-button v-if="scope.row.hash.checkstatus=='2'&&isshowgd" type="danger" size="small" @click="dogdhouse(scope.row)">归档</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <div class="pagination-wrapper">
                <div class="page_box">
                  <table class="page_table">
                    <tr>
                      <td align="center" valign="middle" nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <a>
                          <font>
                            <p @click="searchHouse(1)">首页</p>
                          </font>
                        </a>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <a>
                          <font>
                            <p @click="searchHouse(num-1)">上一页</p>
                          </font>
                        </a>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <a>
                          <font>
                            <p @click="searchHouse(parseInt(num) + 1)">下一页</p>
                          </font>
                        </a>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <a>
                          <font>
                            <p @click="searchHouse(ys)">尾页</p>
                          </font>
                        </a>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <span>
                          <font>第{{this.num}}页</font>
                        </span>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <span>
                          <font>共{{this.ys}}页</font>
                        </span>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <span>
                          <font>共{{this.total}}条记录</font>
                        </span>
                      </td>
                    </tr>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div v-show="this.change=='数据导入'">
          <div class="search_c">
            <div class="import">
              <div class="import-data">
                <p>
                  <test localfiletype="02" tn="filepath" :imagefile.sync="this.uploadFileData" :isupload="'1'">上传导入文件</test>
                  <button @click="uploadfiles" class="submitbutton">导入</button>
                </p>
              </div>
              <p>
                <a href="/images/demo.xlsx" download="demo.xlsx">模版下载</a>
              </p>
              <div class="import-desc">
                <p>导入说明</p>
                <p>1、严格按模板采集数据</p>
                <p>2、严格按模板格式字段顺序</p>
                <p>3、删除各sheet中整行全是空的数据，数据区域单元格设置成文本，所有日期格式必须为：YYYY-MM-DD</p>
                <p>4、导入成功后对个别数据进行抽查，若有问题检查excel是否按上述格式要求进行整理</p>
              </div>
            </div>
          </div>
        </div>
        <!-- <div v-show="this.change=='承租人管理'">
          <div class="search_div">
            <table width="100%" style="margin:30px 0">
              <tr>
                <td width="12%" align="right">类型：</td>
                <td width="21%">
                  <select name class="selectC" v-model="renterData.ttype">
                    <option value="">全部</option>
                    <option
                      :value="item.hash.code_id"
                      v-for="item in rentertypeArr"
                      :key="item.id"
                    >{{item.hash.code_name}}</option>
                  </select>
                </td>
                <td align="right" width="12%">姓名：</td>
                <td width="20%">
                  <input type="text" v-model="renterData.param">
                </td>
                <div class="searchbtn" @click="searchHouse2(1)" style="margin-left:20px">搜索</div>
              </tr>
            </table>

          </div>
          <div style="padding-left: 30px">
            <div class="search-add">
              <span class="zhipai" @click="newrenter">新增</span>
            </div>
            <div class="content_div">
              <el-table
                ref="multipleTable"
                :data="renterList"
                border
                style="width:96%;margin:20px auto"
              >
                <el-table-column type="index" width="50" label="序号"></el-table-column>
                <el-table-column prop="hash.tname" label="姓名"></el-table-column>
                <el-table-column prop="hash.ttypename" label="类型"></el-table-column>
                <el-table-column prop="hash.address" label="地址"></el-table-column>
                <el-table-column prop="hash.linkman" label="联系人"></el-table-column>
                <el-table-column prop="hash.linkphone" label="联系方式"></el-table-column>
                <el-table-column prop="hash.intime" label="录入时间"></el-table-column>
                <el-table-column prop="hash.opname" label="录入人"></el-table-column>

                <el-table-column label="操作" width="260" headerAlign="center">
                  <template slot-scope="scope">
                    <el-button type="primary" size="small" @click="checkrenter(scope.row)">查看</el-button>
                    <el-button
                      type="primary"
                      size="small"
                      @click="editrenter(scope.row)"
                    >编辑</el-button>
                    <el-button
                      type="danger"
                      size="small"
                      @click="deleterenter(scope.row)"
                    >删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <div class="pagination-wrapper">
                <div class="page_box">
                  <table class="page_table">
                    <tr>
                      <td
                        align="center"
                        valign="middle"
                        nowrap="nowrap"
                        style="border:0;padding-right: 10px;"
                      >
                        <a>
                          <font>
                            <p @click="searchHouse2(1)">首页</p>
                          </font>
                        </a>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <a>
                          <font>
                            <p @click="searchHouse2(num2-1)">上一页</p>
                          </font>
                        </a>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <a>
                          <font>
                            <p @click="searchHouse2(parseInt(num2) + 1)">下一页</p>
                          </font>
                        </a>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <a>
                          <font>
                            <p @click="searchHouse2(ys2)">尾页</p>
                          </font>
                        </a>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <span>
                          <font>第{{this.num2}}页</font>
                        </span>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <span>
                          <font>共{{this.ys2}}页</font>
                        </span>
                      </td>
                      <td nowrap="nowrap" style="border:0;padding-right: 10px;">
                        <span>
                          <font>共{{this.total2}}条记录</font>
                        </span>
                      </td>
                    </tr>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>-->
        <div v-show="this.change=='房产地图'">
          <amap></amap>
        </div>
      </div>
    </div>
    <el-dialog title="选择指派对象" :visible.sync="zhipai" width="30%">
      <el-select v-model="chooseZp" placeholder="请选择" style="width:100%">
        <el-option v-for="item in zpArr" :key="item.hash.orgid" :value="item.hash.orgid" :label="item.hash.orgname.replace(/;/g,'')">{{item.hash.orgname.replace(/;/g,"&nbsp;")}}</el-option>
      </el-select>
      <span slot="footer" class="dialog-footer">
        <el-button @click="zhipai=false">取 消</el-button>
        <el-button type="primary" @click="submitzp">确 定</el-button>
      </span>
    </el-dialog>
    <!-- <el-dialog
      :title="rentertitle"
      :visible.sync="showrenter"
      width="50%"
    >
      <el-form labelWidth="140px" :disabled="this.rentertitle=='查看承租人'">
        <el-form-item label="姓名：" class="is-required">
          <el-input v-model="renterData.tname"></el-input>
        </el-form-item>
        <el-form-item label="类型：" class="is-required">
          <el-select placeholder="请选择" style="width:100%" v-model="renterData.ttype">
            <el-option
              v-for="item in rentertypeArr"
              :key="item.hash.code_name"
              :label="item.hash.code_name"
              :value="item.hash.code_id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="地址：" class="is-required">
          <el-input v-model="renterData.address"></el-input>
        </el-form-item>
        <el-form-item label="联系人：" class="is-required">
          <el-input v-model="renterData.linkman"></el-input>
        </el-form-item>
        <el-form-item label="联系方式：" class="is-required">
          <el-input type="number" v-model="renterData.linkphone"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer" v-show="this.rentertitle!=='查看承租人'">
        <el-button @click="showrenter = false">取 消</el-button>
        <el-button type="primary" @click="savenewrenter" v-if="this.rentertitle=='新增承租人'">确 定</el-button>
        <el-button type="primary" @click="saveedit" v-else>保 存</el-button>
      </span>
    </el-dialog>-->
  </div>
</template>
<script type="text/ecmascript-6">

import test from '~/components/common/upload/test.vue';
import amap from '~/components/common/amap.vue';
import pagination from '~/components/common/pagination/pagination';
import HHeader from '~/components/common/header/Mheader';
import NuxtLink from '../.nuxt/components/nuxt-link';

export default {
  data () {
    return {
      showzb: false,
      certnum: '',
      renterList: [],
      rentertitle: '新增承租人',
      renterData: { ttype: '' },
      rentertypeArr: [],
      showrenter: false,
      dept: localStorage.getItem('dept'),
      pid: localStorage.getItem('pid'),
      zhipai: false,
      sideMenu: [],
      choosedh: [],
      danwei2: '',
      chooseZp: '',
      fileList: [],
      zpArr: [],
      change: 'map1',
      showTitle: '',
      checkstatus: '',
      jiedao: '',
      village: '',
      isshowgd: false,
      housedata: [],
      housedata2: [],
      housedata3: [],
      ts: this.newStore(),
      alldata: [],
      regionArr: [],
      hstatusArr: [],
      region: '',
      hstatus: '',
      htype: '',
      haddr: '',
      hnum: '',
      num2: 1,
      total2: 0, // 数据总数
      ys2: 0,
      limit2: '30', // 每组有多少条数据
      uploadFileData: {},
      total: 0, // 数据总数
      num: 1, // 当前页
      ys: 0,
      limit: '30', // 每组有多少条数据
    };
  },
  created () {
    this.hnum = this.$route.query.zcbh;
    console.log(this.$route);
    this.checkgd2();
    this.isshowzp();
    this.getSelectList('13', 'regionArr');
    this.getSelectList('15', 'hstatusArr');
    this.getSelectList('07', 'rentertypeArr');
    this.changetab('房产清单');
    this.getzp();
    this.getjigou();
    this.getleixing();
    // this.searchHouse(this.num);
    this.getsideMenu();
  },
  methods: {
    checkgd2 () {
      const req = {
        handle: '67A5B6FEF17D97DECF116BDF95B95C0BF829FBCD1B3C6C87ABE555654F5B8C21',
        token: localStorage.getItem('token'),
        funcid: '204140',
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        if (ts.d.data.operation1[0].hash.cou == '0') {
          this.isshowgd = false;
        } else {
          this.isshowgd = true;
        }
      });
    },
    dogdhouse (item) {
      const res = {
        token: localStorage.getItem('token'),
        handle: '76ABA4BE996F68CE417AAAFED0C1AC070B1B2B21358602E87D84A201A1DEE871',
        hid: item.hash.hid,
      };
      this.spost(this.ts, '/mainservlet', res).then((ts) => {
        if (ts.d.data.operation1[0].hash.check1 == '1') {
          this.$confirm('确认归档？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          })
            .then(() => {
              const res2 = {
                token: localStorage.getItem('token'),
                handle: '76ABA4BE996F68CE369E74C0A84D16DAC2805704C382F40C8CE82841BFAE7358',
                hid: item.hash.hid,
              };
              this.spost(this.ts, '/mainservlet', res2).then((ts) => {
                this.$message({
                  type: 'success',
                  message: '归档成功!',
                });
                this.searchHouse(this.num);
              });
            })
            .catch(() => {
              this.$message({
                type: 'info',
                message: '已取消',
              });
            });
        } else {
          this.$message.error('该房产下有未归档房屋或用途，请归档后再提交');
        }
      });
    },
    // deleterenter(item) {
    //   this.$confirm('确认删除？', '提示', {
    //     confirmButtonText: '确定',
    //     cancelButtonText: '取消',
    //     type: 'warning',
    //   })
    //     .then(() => {
    //       const res = {
    //         token: localStorage.getItem('token'),
    //         handle: 'D721B46D2973C0398677806905CDAEA6CAD7F240D2E4ADC8EF0F7C1279F4C8A3',
    //         tid: item.hash.tid,
    //       };
    //       this.spost(this.ts, '/mainservlet', res).then((ts) => {
    //         this.$message({
    //           type: 'success',
    //           message: '删除成功!',
    //         });
    //         this.searchHouse2(this.num);
    //       });
    //     })
    //     .catch(() => {
    //       this.$message({
    //         type: 'info',
    //         message: '已取消',
    //       });
    //     });
    // },
    // saveedit() {
    //   if (this.renterData.tname == undefined) {
    //     this.$message('姓名不能为空');
    //     return;
    //   }
    //   if (this.renterData.ttype == '') {
    //     this.$message('类型不能为空');
    //     return;
    //   }
    //   if (this.renterData.address == undefined) {
    //     this.$message('地址不能为空');
    //     return;
    //   }
    //   if (this.renterData.linkman == undefined) {
    //     this.$message('联系人不能为空');
    //     return;
    //   }
    //   if (this.renterData.linkphone == undefined) {
    //     this.$message('联系方式不能为空');
    //     return;
    //   }

    //   this.$confirm('确认保存？', '提示', {
    //     confirmButtonText: '确定',
    //     cancelButtonText: '取消',
    //     type: 'warning',
    //   }).then(() => {
    //     const res = {
    //       handle: 'D721B46D2973C039C6E0C60985F2781D7AB2C71CE3E3D3AAEF0F7C1279F4C8A3',
    //       token: localStorage.getItem('token'),
    //       tid: this.renterData.tid,
    //       tname: this.renterData.tname,
    //       ttype: this.renterData.ttype,
    //       linkman: this.renterData.linkman,
    //       address: this.renterData.address,
    //       linkphone: this.renterData.linkphone,
    //     };
    //     this.spost(this.ts, '/mainservlet', res).then((ts) => {
    //       this.$message({
    //         type: 'success',
    //         message: '保存成功!',
    //       });
    //       this.searchHouse2(this.num2);
    //       this.showrenter = false;
    //     });
    //   }).catch(() => {
    //     this.$message({
    //       type: 'info',
    //       message: '已取消',
    //     });
    //   });
    // },
    // editrenter(item) {
    //   this.renterData = { ttype: '' };
    //   this.rentertitle = '编辑承租人';
    //   this.showrenter = true;
    //   this.renterData = item.hash;
    // },
    // checkrenter(item) {
    //   console.log(item);
    //   this.showrenter = true;
    //   this.rentertitle = '查看承租人';
    //   this.renterData = item.hash;
    // },
    // newrenter() {
    //   this.rentertitle = '新增承租人';
    //   this.renterData = { ttype: '' };
    //   this.showrenter = true;
    // },
    // savenewrenter() {
    //   console.log(this.renterData.tname);
    //   if (this.renterData.tname == undefined) {
    //     this.$message('姓名不能为空');
    //     return;
    //   }
    //   if (this.renterData.ttype == undefined) {
    //     this.$message('类型不能为空');
    //     return;
    //   }
    //   if (this.renterData.address == undefined) {
    //     this.$message('地址不能为空');
    //     return;
    //   }
    //   if (this.renterData.linkman == undefined) {
    //     this.$message('联系人不能为空');
    //     return;
    //   }
    //   if (this.renterData.linkphone == undefined) {
    //     this.$message('联系方式不能为空');
    //     return;
    //   }

    //   this.$confirm('确认新增？', '提示', {
    //     confirmButtonText: '确定',
    //     cancelButtonText: '取消',
    //     type: 'warning',
    //   }).then(() => {
    //     const res = {
    //       handle: 'D721B46D2973C039CB316AB2715FEA9CBC7009E576825410BFF0B9210751F692',
    //       token: localStorage.getItem('token'),
    //       tname: this.renterData.tname,
    //       ttype: this.renterData.ttype,
    //       linkman: this.renterData.linkman,
    //       address: this.renterData.address,
    //       linkphone: this.renterData.linkphone,
    //     };
    //     this.spost(this.ts, '/mainservlet', res).then((ts) => {
    //       this.$message({
    //         type: 'success',
    //         message: '新增成功!',
    //       });
    //       this.searchHouse2(this.num2);
    //       this.showrenter = false;
    //     });
    //   }).catch(() => {
    //     this.$message({
    //       type: 'info',
    //       message: '已取消',
    //     });
    //   });
    // },
    checkboxInit (row) {
      console.log(row);
      if (row.hash.checkstatus == '0' || row.hash.checkstatus == '2') {
        return 1;
      }
      return 0;
    },
    submitzp () {
      const hidarr = [];
      for (let i = 0; i < this.choosedh.length; i += 1) {
        hidarr.push(this.choosedh[i].hash.hid);
      }
      const req = {
        handle:
          '76ABA4BE996F68CEA0781CC2B96020E7EFAD419108D81EFD64EDEA66339D7026',
        token: localStorage.getItem('token'),
        hid: hidarr,
        glorg: this.chooseZp,
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        this.$message({
          type: 'success',
          message: '指派成功',
        });
        this.zhipai = false;
        this.searchHouse(this.num);
      });
    },
    handleSelectionChange (val) {
      this.choosedh = val;
    },
    dozhipai () {
      if (this.choosedh.length < 1) {
        this.$message({
          type: 'error',
          message: '请先在表格中勾选房产',
        });
        return;
      }
      this.zhipai = true;
    },
    goDetail (item) {
      const req = {
        handle:
          '76ABA4BE996F68CE45CC3204026CFD987E7D576F016578F549648E3FE0154372',
        token: localStorage.getItem('token'),
        hid: item.hash.hid,
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        this.$router.push({
          name: 'detailInfo',
          query: {
            hid: item.hash.hid,
            xh: item.hash.xh,
          },
        });
      });
    },
    goSearchinfo (item) {
      this.$router.push({
        name: 'searchDetail',
        query: {
          hid: item.hash.hid,
          xh: item.hash.xh,
        },
      });
    },
    isshowzp () {
      const req = {
        handle: '67A5B6FEF17D97DECF116BDF95B95C0BF829FBCD1B3C6C87ABE555654F5B8C21',
        token: localStorage.getItem('token'),
        funcid: '204124',
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        if (ts.d.data.operation1[0].hash.cou == '0') {
          this.showzb = false;
        } else {
          this.showzb = true;
        }
      });
    },
    getsideMenu () {
      const req = {
        handle: '67A5B6FEF17D97DECF116BDF95B95C0B078C37EB4CBA2359',
        token: localStorage.getItem('token'),
        supid: '204000',
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        // console.log(ts.d);
        this.sideMenu = ts.d.data.operation1;
      });
    },
    changetab (tab) {
      this.change = tab;
      this.showTitle = this.change;
      if (this.change == '房产清单') {
        this.searchHouse(1);
      }
      if (this.change == '承租人管理') {
        this.searchHouse2(1);
      }
    },
    getTestinput (imgPath, tn) {
      this[tn] = imgPath;
    },
    getzp () {
      const req = {
        handle: '67A5B6FEF17D97DECF116BDF95B95C0BA442E5E7D07AB87B614E39228DA82270',
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {

        this.zpArr = ts.d.data.operation1;
        if (this.zpArr.length > 0) {
          const a = (this.zpArr[0].hash.orgname.match(/;/g) || []).length;
          console.log(a);
          for (let i = 0; i < this.zpArr.length; i += 1) {
            this.zpArr[i].hash.orgname = this.zpArr[i].hash.orgname.substring(a);
            console.log(this.zpArr[i].hash.orgname);
          }
        }
      });
    },
    getjigou () {
      const req = {
        handle: '76ABA4BE996F68CEF9A9763329C1A0DD0ECC64278BA7F847',
        suporg: '1',
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        this.housedata = ts.d.data.operation1;
      });
    },
    getjigou2 () {
      const req = {
        handle: '76ABA4BE996F68CEF9A9763329C1A0DD0ECC64278BA7F847',
        suporg: this.jiedao,
      };
      if (this.jiedao != '') {
        this.spost(this.ts, '/mainservlet', req).then((ts) => {
          this.housedata2 = ts.d.data.operation1;
        });
      } else {
        this.housedata2 = [];
      }
    },
    getleixing () {
      const req = {
        handle: '76ABA4BE996F68CEF9A9763329C1A0DD1C1E493C3971E71F',
        supid: '1',
        codetype: '01',
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        this.housedata3 = ts.d.data.operation1;
      });
    },
    searchHouse (p_num) {
      if (p_num < 1) {
        p_num = 1;
      }
      if (p_num > this.ys && this.ys > 0) {
        p_num = this.ys;
      }
      const res = {
        handle: '76ABA4BE996F68CE7B9160D0DE918C4B9EAEF75EC136D805',
        token: localStorage.getItem('token'),
        jiedao: this.jiedao,
        hnum: this.hnum,
        htype: this.htype,
        haddr: this.haddr,
        danwei2: this.danwei2,
        dstatus: this.hstatus,
        region: this.region,
        checkstatus: this.checkstatus,
        certnum: this.certnum,
        start: p_num,
        limit: '50',
      };
      this.spost(this.ts, '/mainservlet', res).then((ts) => {
        console.log(ts.d);
        this.alldata = ts.d.data.operation1;
        this.total = ts.d.data.operation2[0].hash.allrs;
        this.ys = ts.d.data.operation2[0].hash.ys;
        this.num = ts.d.data.operation2[0].hash.beg;
        this.limit = ts.d.data.operation2[0].hash.limit;
      });
    },
    searchHouse2 (p_num) {
      if (p_num < 1) {
        p_num = 1;
      }
      if (p_num > this.ys2 && this.ys2 > 0) {
        p_num = this.ys2;
      }
      const res = {
        handle:
          'D721B46D2973C039F541EED792A24A2478A9D2FDFE2446E0CD3A43E9777C4E90',
        token: localStorage.getItem('token'),
        start: p_num,
        param: this.renterData.param,
        ttype: this.renterData.ttype,
        limit: '50',
      };
      this.spost(this.ts, '/mainservlet', res).then((ts) => {
        this.renterList = ts.d.data.operation1;
        this.total2 = ts.d.data.operation2[0].hash.allrs;
        this.ys2 = ts.d.data.operation2[0].hash.ys;
        this.num2 = ts.d.data.operation2[0].hash.beg;
        this.limit2 = ts.d.data.operation2[0].hash.limit;
      });
    },
    getSelectList (codetype, td) {
      const req = {
        handle: '76ABA4BE996F68CEF9A9763329C1A0DD1C1E493C3971E71F',
        token: localStorage.getItem('token'),
        supid: '',
        codetype,
      };
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        // console.log(ts.d.data.operation1);
        this[td] = ts.d.data.operation1;
      });
    },
    deleteItem (item) {
      this.$confirm('确认删除？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          const res = {
            token: localStorage.getItem('token'),
            handle: '76ABA4BE996F68CEB3F2193D08E31332401947FC9DF09017',
            hid: item.hash.hid,
          };
          this.spost(this.ts, '/mainservlet', res).then((ts) => {
            this.$message({
              type: 'success',
              message: '删除成功!',
            });
            this.searchHouse(this.num);
          });
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消',
          });
        });
    },
    submitUpload () {
      // this.$refs.upload.submit();
      alert('上传中...');
    },
    uploadfiles () {
      console.log(this.uploadFileData.filepath);

      if (this.uploadFileData.filepath == '' || this.uploadFileData.filepath == undefined) {
        this.$message({
          type: 'error',
          message: '请先上传文件',
        });
        return;
      }
      this.$confirm('确认导入？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        const res = {
          handle:
            '76ABA4BE996F68CE7B9160D0DE918C4BDD7907C7C61CB39EBFF0B9210751F692',
          token: localStorage.getItem('token'),
          inputfile: this.uploadFileData.filepath,
        };
        this.spost(this.ts, '/mainservlet', res).then((ts) => {
          this.$message('导入成功！');
        });
      });
    },
  },
  components: {
    NuxtLink,
    HHeader,
    test,
    pagination,
    amap,
  },
};
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
.content_div>>>.el-table--enable-row-transition .el-table__body td {
  text-align: center;
}

.content_div>>>.el-table th>.cell {
  text-align: center;
}

.zhipai {
  width: 80px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  border-radius: 5px;
  background: #69f;
  padding: 9px 15px;
  color: #fff;
  margin-left: 10px;
}

.pagination-wrapper {
  height: 60px;
  text-align: center;

  .page_table {
    margin: 0 auto;
    border: 0;
  }

  a {
    &:hover {
      text-decoration: underline;
      color: blue;
    }
  }

  .desc {
    display: inline-block;
    font-size: 14px;

    span {
      color: #666;

      i {
        padding: 0 3px;
        font-size: 16px;
        color: #25a4bb;
      }
    }
  }
}

.search_div {
  margin: 10px 0 10px 0px;
  padding: 8px 55px 8px 0px;
  border-bottom: 1px solid #ddd;
}

.search_div td {
  border: none !important;
  padding: 5px 8px;
}

.search_div input[type='text'], .search_div select {
  box-sizing: content-box;
  width: 100%;
  padding: 4px 0;
  text-indent: 5px;
  margin-left: 5px;
  border-radius: 2px;
  border: 1px solid #ccc;
  color: #333;
}

.searchbtn {
  margin: 10px auto;
  width: 60px;
  height: 34px;
  line-height: 34px;
  text-align: center;
  font-size: 14px;
  background-color: #69f;
  color: #fff;
  border-radius: 5px;
  font-weight: 400;
  cursor: pointer;
}

.content_div {
  margin: 5px 8px;
  padding: 0 15px 0 0;
}

.lin_nor {
  color: #409eff;
}

.lin_nor:hover {
  text-decoration: underline;
}

.submitbutton {
  padding: 4px 30px;
  border-radius: 3px;
  background: #69f;
  color: #fff;
  margin-top: 20px;
}

.import-data >>> .el-button--small, .el-button--small.is-round {
  padding: 12px 20px;
}

.import-data >>> .el-upload-list__item {
  width: 400px;
  background: #f1f1f1;
  margin: 10px auto;
  line-height: 40px;
}

.houseManage {
  width: 100%;

  .content {
    display: flex;
    width: 100%;
    min-height: 600px;

    .sidebar {
      flex: 0 0 200px;
      width: 200px;
      background: #F2F2F2;
      border-right: 1px solid #ccc;

      .main-title {
        flex: 1;
        width: 100%;
        height: 44px;
        line-height: 44px;
        border-bottom: 2px solid #fff;
        color: #13227A;
        font-size: 0;

        .iconfont {
          display: inline-block;
          margin-right: 15px;
          font-size: 20px;
          text-indent: 1em;
        }

        .text {
          display: inline-block;
          font-weight: 600;
        }
      }

      .menu {
        display: block;
        width: 100%;
        text-indent: 2em;
        cursor: pointer;
        background: #f1f1f1;

        .title {
          height: 48px;
          line-height: 48px;
          border-bottom: 1px solid #ccc;
          padding-left: 10px;

          &.choosed {
            background: #fff;
          }
        }
      }
    }

    .main-content {
      flex: 1;
      min-height: 780px;

      .search_h {
        height: 44px;
        line-height: 44px;
        padding-left: 20px;
        background: #f2f2f2;
        border-bottom: 2px solid #fff;

        p {
          float: left;
          font-size: 16px;

          a {
            color: #69f;
          }

          span {
            font-size: 14px;
            padding-left: 15px;
          }

          .add-content {
            position: absolute;
            right: 20px;
            top: 35px;
            width: 100px;
            display: none;
            background: #fff;
            border: 1px solid #ccc;

            span {
              display: block;
              text-align: center;

              &:hover {
                background: #eee;
              }
            }
          }

          &:hover {
            .add-content {
              display: block;
            }
          }
        }
      }

      .search_c {
        width: 100%;
        padding: 8px 15px;
        border-bottom: 1px solid #f1f1f1;

        .billlist {
          margin-bottom: 15px;

          span {
            font-size: 14px;
            display: inline-block;
            width: 30%;
            min-width: 100px;

            &:first-child {
              padding-left: 20px;
            }

            .selectC {
              box-sizing: content-box;
              width: 190px;
              padding: 4px 5px;
              border-radius: 2px;
              font-size: 14px;
              color: #333;
              border: 1px solid #ccc;
            }

            input {
              box-sizing: content-box;
              width: 190px;
              padding: 4px 5px;
              margin-left: 5px;
              border-radius: 2px;
              border: 1px solid #ccc;
              color: #333;
            }
          }
        }

        .search {
          margin: 0 auto;
          width: 80px;
          height: 30px;
          line-height: 30px;
          text-align: center;
          font-size: 14px;
          background-color: #69f;
          color: #fff;
          border-radius: 5px;
          font-weight: 400;
        }

        .import {
          .import-data {
            margin-bottom: 30px;
            margin-top: 30px;
            text-align: center;

            .text {
              font-size: 16px;
              display: inline-block;
              padding-top: 9px;
              margin-right: 15px;
            }

            input {
              display: inline-block;
              vertical-align: top;
              height: 34px;
              margin-right: 15px;
              border: 1px solid #ccc;
            }

            .select {
              display: inline-block;
              vertical-align: top;
              padding: 10px 15px;
              background: #87B87F;
              color: #fff;
            }
          }

          .import-btn {
            margin-bottom: 30px;

            span {
              display: inline-block;
              vertical-align: top;
              padding: 12px;
              background: #87B87F;
              color: #fff;

              &:nth-of-type(1) {
                margin-right: 30px;
              }
            }
          }

          .import-desc {
            position: fixed;
            top: 500px;

            p {
              font-size: 16px;
              line-height: 24px;
              color: #666;
            }
          }
        }
      }

      .search-add {
        float: right;
        margin: 8px 25px 15px 10px;
        cursor: pointer;
        float: right;
        margin-right: 10%;

        .add-btn {
          width: 80px;
          height: 30px;
          line-height: 30px;
          text-align: center;
          border-radius: 5px;
          background: #69f;

          span {
            font-size: 14px;
            color: #fff;
          }
        }
      }
    }
  }
}
</style>
